package cn.howxu.yichen_ovo.init;

import cn.howxu.yichen_ovo.YiChenOVO;
import cn.howxu.yichen_ovo.common.entity.CompletionistBannerEntity;
import cn.howxu.yichen_ovo.common.entity.DollEntity;
import cn.howxu.yichen_ovo.common.entity.EntityPainting;
import cn.howxu.yichen_ovo.common.entity.StorageBlockEntity;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;

import java.util.HashSet;

/**
 * @description: TODO
 * @author: HowXu
 * @date: 2025/9/12 18:30
 */
public class ModEntities {
    public static final DeferredRegister<EntityType<?>> ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, YiChenOVO.MODID);
    public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, YiChenOVO.MODID);

    public static RegistryObject<EntityType<DollEntity>> DOLL = ENTITY_TYPES.register("doll_entity", () ->
            EntityType.Builder.<DollEntity>of(DollEntity::new, MobCategory.MISC)
                    .sized(0.75f, 0.75f)
                    .clientTrackingRange(10)
                    .build("doll_entity"));

    public static RegistryObject<BlockEntityType<CompletionistBannerEntity>> FLAG = BLOCK_ENTITY_TYPES.register("flag", () -> 
            BlockEntityType.Builder.of(CompletionistBannerEntity::new, ModBlocks.FLAG.get(), ModBlocks.FLAG_WALL.get()).build(null));

    public static final RegistryObject<BlockEntityType<StorageBlockEntity>> STORAGE_ENTITY = BLOCK_ENTITY_TYPES.register("storage", () -> 
            BlockEntityType.Builder.of(StorageBlockEntity::new, ModBlocks.WINE.get()).build(null));

    public static final RegistryObject<EntityType<EntityPainting>> PAINTING = ENTITY_TYPES.register("painting", () ->
            register("painting", EntityType.Builder.<EntityPainting>of(EntityPainting::new, MobCategory.MISC)
                    .sized(0.5F, 0.5F)
                    .clientTrackingRange(10).updateInterval(Integer.MAX_VALUE)
                    .setCustomClientFactory(EntityPainting::new)));

    public static <T extends Entity> EntityType<T> register(String id, EntityType.Builder<T> builder) {
        return builder.build(id);
    }
}
